<?php require admin_tpl('header');?>

<div class="tab">
<ul>
	<li><a href="?mod=ucenter&ac=main" <?php if ($ac == 'main') echo 'class="on"';?>>个人信息</a></li>
	<li><a href="?mod=ucenter&ac=profile" <?php if ($ac == 'profile') echo 'class="on"';?>>资料修改</a></li>
	<li><a href="?mod=ucenter&ac=permission" <?php if ($ac == 'permission') echo 'class="on"';?>>我的权限</a></li>
	<li><a href="?mod=ucenter&ac=comment" <?php if ($ac == 'comment') echo 'class="on"';?>>我的评论</a></li>
	<li><a href="?mod=ucenter&ac=atme" <?php if ($ac == 'atme') echo 'class="on"';?>>回复我的</a></li>
</ul>
</div>
<div class="main">

	<?php if ( $ac == 'main') { ?>

	<table class="sub">
		<tr>
			<td width="80" align="right">昵称：</td>
			<td><?php echo $userinfo['username'];?></td>
		</tr>
		<tr>
			<td align="right">级别：</td>
			<td>
			<?php
			switch ($userinfo['group']) {
				case 'admin' : echo '管理员'; break;
				case 'author' : echo '作者'; break;
				case 'user' : echo '会员'; break;
			}
			?>
			</td>
		</tr>
		<tr>
			<td align="right">性别：</td>
			<td><?php echo ($userinfo['sex'] == 0 ? '保密' : ( $userinfo['sex'] == 1 ? '男' : '女'));?></td>
		</tr>
		<tr>
			<td align="right">Email：</td>
			<td><?php echo empty($userinfo['email']) ? '未填写' : $userinfo['email'];?></td>
		</tr>
		<tr>
			<td align="right">主页：</td>
			<td><?php echo empty($userinfo['url']) ? '无' : $userinfo['url'];?></td>
		</tr>
		<tr>
			<td align="right">文章：</td>
			<td><b style="color:green"><?php echo $userinfo['posts']; ?></b> 篇</td>
		</tr>
		<tr>
			<td align="right">评论：</td>
			<td><b style="color:#f60"><?php echo $userinfo['comments']; ?></b> 条</td>
		</tr>
		<tr>
			<td align="right">注册时间：</td>
			<td><?php echo get_date($userinfo['regtime'],'Y-m-d H:i:s');?></td>
		</tr>
		<tr>
			<td align="right">最后登录：</td>
			<td><?php echo get_date($userinfo['lastlogin'],'Y-m-d H:i:s');?></td>
		</tr>
		<tr>
			<td align="right">最后登录IP：</td>
			<td><?php echo $userinfo['lastip']; ?></td>
		</tr>
		<tr>
			<td align="right">登录次数：</td>
			<td><?php echo $userinfo['logincount']?> 次</td>
		</tr>		
	</table>

	<?php } elseif ( $ac == 'profile' ) { ?>
	<form name="profile" method="post" action="?mod=ucenter&ac=profile">
	<input type="hidden" name="dosubmit" value="yes" />
		<table class="sub" cellspacing="0">
			<tr>
				<td width="80" align="right">用户名：</td>
				<td><input type="text" name="username" class="input"  value="<?php echo $userinfo['username']?>" disabled="disabled" size="15" /></td>
			</tr>
			<tr>
				<td align="right">E-Mail：</td>
				<td><input type="text" name="email" class="input" value="<?php echo $userinfo['email']?>" disabled="disabled"  size="30" /></td>
			</tr>
			<tr>
				<td width="80" align="right">原密码：</td>
				<td><input type="password" name="password" class="input" size="30" /> <span style="color:red">*</span></td>
			</tr>
			<tr>
				<td align="right">新密码：</td>
				<td><input type="password" name="newpassword" class="input" size="30" /></td>
			</tr>
			<tr>
				<td align="right">确认密码：</td>
				<td><input type="password" name="newpassword2" class="input" size="30" /></td>
			</tr>
			<tr>
				<td align="right">性别：</td>
				<td>
				<input type="radio" class="radio" name="sex" value="0" <?php if ($userinfo['sex']==0) {echo 'checked="checked"';}?> /> 保密　
				<input type="radio" class="radio" name="sex" value="1" <?php if ($userinfo['sex']==1) {echo 'checked="checked"';}?> /> 男　
				<input type="radio" class="radio" name="sex" value="2" <?php if ($userinfo['sex']==2) {echo 'checked="checked"';}?> /> 女
				</td>
			</tr>	
			<tr>
				<td align="right">主页：</td>
				<td><input type="text" name="url" class="input" value="<?php echo $userinfo['url']?>" size="30" /></td>
			</tr>
			<tr class="bg2">
				<td></td>
				<td><input type="submit" class="button" value=" 提交修改 " /></td>
			</tr>
		</table>
	</form>
	<?php } elseif ( $ac == 'permission' ) { ?>

	<table class="sub">
	<?php if ( is_admin() ) { ?>
		<tr>
			<td width="100" align="right">文章管理权限：</td>
			<td>
			发布文章  <?php echo check_perm('blog','post') ? '<span style="color:green;">√</span>' : '<span style="color:red">×</span>';?>
			编辑文章  <?php echo check_perm('blog','edit') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			审核文章 <?php echo check_perm('blog','check') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			删除文章 <?php echo check_perm('blog','del') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			移动文章 <?php echo check_perm('blog','move') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			添加分类 <?php echo check_perm('blog','addcate') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			编辑分类 <?php echo check_perm('blog','editcate') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			删除分类 <?php echo check_perm('blog','delcate') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			</td>
		</tr>
		<tr>
			<td width="100" align="right">评论管理权限：</td>
			<td>
			审核评论 <?php echo check_perm('comment','check') ? '<span style="color:green;">√</span>' : '<span style="color:red">×</span>';?>
			编辑评论 <?php echo check_perm('comment','edit') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			回复评论 <?php echo check_perm('comment','reply') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			删除评论 <?php echo check_perm('comment','del') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			</td>
		</tr>
		<tr>
			<td width="100" align="right">链接管理权限：</td>
			<td>
			添加链接 <?php echo check_perm('link','add') ? '<span style="color:green;">√</span>' : '<span style="color:red">×</span>';?>
			审核链接 <?php echo check_perm('link','check') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			编辑链接 <?php echo check_perm('link','edit') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			删除链接 <?php echo check_perm('link','del') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			链接分类 <?php echo check_perm('link','cate') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			</td>
		</tr>
		<tr>
			<td width="100" align="right">其他管理权限：</td>
			<td>
			附件管理 <?php echo check_perm('attach') ? '<span style="color:green;">√</span>' : '<span style="color:red">×</span>';?>
			标签管理 <?php echo check_perm('tag') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			</td>
		</tr>
	<?php } ?>
	<?php if ( $_USER['group'] == 'author' ) { ?>
		<tr>
			<td width="100" align="right">文章权限：</td>
			<td>
			 发布文章 <?php echo check_perm('blog','post') ? '<span style="color:green;">√</span>' : '<span style="color:red">×</span>';?>
			文章需要管理员审核 <?php echo check_perm('blog','needcheck') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			允许上传附件 <?php echo check_perm('blog','upload') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			编辑自己的文章 <?php echo check_perm('blog','edit') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			删除自己的文章 <?php echo check_perm('blog','del') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			</td>
		</tr>
	<?php }?>
		<tr>
			<td width="100" align="right">前台权限：</td>
			<td>
			发布评论 <?php echo check_perm('comment','post') ? '<span style="color:green;">√</span>' : '<span style="color:red">×</span>';?>
			评论需要审核 <?php echo check_perm('comment','needcheck') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			评论需要验证码 <?php echo check_perm('comment','seccode') ? '<span style="color:green">√</span>' : '<span style="color:red">×</span>';?>
			<br />
			评论时间间隔：<?php echo (int)$_USER['permission']['comment']['timelimit']?> 秒<br />
			评论字数限制：<?php echo $_USER['permission']['comment']['maxchar']?$_USER['permission']['comment']['maxchar']:'不限'?> 字节
			</td>
		</tr>
	</table>

	<?php } elseif ( $ac == 'comment' || $ac == 'atme' ) { ?>

		<table class="datalist" cellspacing="0">
			<tr>
				<th class="firstcol">评论内容</th>
				<th width="300">所在文章</th>
			</tr>
			<?php if ( !$count ) {?>
			<tr>
				<td>暂无记录...</td>
			</tr>
			<?php 
			} else {
			$i=0;
			foreach ($result as $row) {
			?>
			<tr <?php echo (++$i % 2 == 0 ? 'class="bg2"' : ''); ?> id="comment_<?php echo $row['id']?>" <?php echo $row['status'] ? '' : 'class="highlight"';?>>
				<td valign="top" style="font-size:14px;padding:5px;">
				<span><?php echo avatar($row['email']);?></span>
				<div style="color:#666;font-size:11px"><a href="mailto:<?php echo $row['email']?>"><?php echo $row['author']?></a> 发布于 <a href="<?php echo url('mod=post&id='.$row['postid'])?>#comment-<?php echo $row['id']?>" target="_blank" title="查看评论"><?php echo get_date($row['dateline']);?></a>，IP：<?php echo $row['ip']?></div>
					<?php
						echo cut_str($row['content'],255);
						if ( !$row['status'] ) echo ' <font color="red">[审核中]</font>';
					?>
				</td>
				<td valign="top" style="color:#666;font-size:11px">
				<a href="<?php echo url('mod=post&id='.$row['postid'])?>" target="_blank"><?php echo cut_str($row['title']) ?></a>
				<br />发表于 <?php echo get_date($row['posttime'])?>
				</td>
			</tr>
			<?php }?>
			<tr>
				<td colspan="3"><?php echo multipage()?></td>
			</tr>
			<?php } ?>
		</table>

	<?php } ?>
</div>

<?php require admin_tpl('footer');?>